package com.ksyun.seckill.constants;

/**
 * 抢购服务版本.
 *
 * @author ksc
 */
public enum SecKillImplVer {
    V0("V0", "无并发控制"),

    V1("V1", "悲观锁"),

    V2("V2", "乐观锁"),

    V3("V3", "乐观锁（CAS自旋)"),

    V4("V4", "乐观锁（乐观锁的变种)"),

    V5("V5", "分布式锁"),

    V6("V6","最终版本:redis＋lua抢购；异步下单"),

    V7("V7","结课大作业");

    public final String ver;

    public final String descr;

    SecKillImplVer(String ver, String descr) {
        this.ver = ver;
        this.descr = descr;
    }

    public static SecKillImplVer of(String ver) {
        SecKillImplVer[] secKillImplVers = values();
        for (SecKillImplVer secKillImplVer : secKillImplVers) {
            if (secKillImplVer.ver.equalsIgnoreCase(ver)) {
                return secKillImplVer;
            }
        }
        throw new IllegalArgumentException("不合法的SecKillImplVer:" + ver);
    }

}
